<?php
namespace  Home\Controller;
use Think\Controller;

class ExperienceController extends Controller {



    private static $adModel;
    private static $adTypeModel;
    private static $columnModel;
    private static $newsModel;
    private static $aboutPic;


    public function  __construct()
    {
        parent::__construct();

        if(self::$columnModel==null){
            self::$columnModel=M('column');
        }

        if(self::$adModel==null){
            self::$adModel=M('plug_ad');
        }

        if(self::$adTypeModel==null){
            self::$adTypeModel=M('plug_adtype');
        }
        if(self::$aboutPic==null){
            $adTypeModel=self::$adTypeModel;
            $type['plug_adtype_name'] = "走进七果banner图";
            $adtype = $adTypeModel->where($type)->find()['plug_adtype_id'];

            $adModel = self::$adModel;
            $condition['plug_ad_adtypeid'] = $adtype;
            $condition['plug_ad_checkid'] = 1;
            $condition['plug_ad_open'] = 1;
            $about = $adModel->field('plug_ad_pic')->order('plug_ad_order')->where($condition)->find();
            self::$aboutPic=$about;
        }

        if(self::$newsModel==null){
            self::$newsModel=M('news');
        }

    }

    public function experience(){

        $columnModel=self::$columnModel;
        $condition3['column_name']= '装修体验';
        $condition3['column_type']= 1;
        $condition3['column_open']= 1;
        $column_leftid=$columnModel->where($condition3)->getField('c_id');

        $condition5['column_open']= 1;
        $condition5['column_type']= 3;
        $condition5['column_leftid']=$column_leftid;
        $columns=$columnModel->where($condition5)->order('column_order')->Field('c_id,column_name')->select();
        $this->assign('columns', $columns);


        $condition4['column_name']= '产品分类';
        $condition4['column_type']= 1;
        $condition4['column_open']= 1;
        $column_leftid=$columnModel->where($condition4)->getField('c_id');
        $condition5['column_open']= 1;
        $condition5['column_type']= 3;
        $condition5['column_leftid']=$column_leftid;
        $columns2=$columnModel->where($condition5)->order('column_order')->Field('c_id,column_name')->select();
        $this->assign('columns2', $columns2);


        $this->display();



    }

    //装修体验
    public function  zxty(){

        $columnModel=self::$columnModel;
        $newsModel=self::$newsModel;
        $column_name=trim(htmlspecialchars($_POST['name']));
        $condition['column_name']=$column_name;
        $condition['column_open']=1;
        $c_id=$columnModel->where($condition)->find()['c_id'];

        $condition1['news_back']=0;
        $condition1['news_open']=1;
        $condition1['news_columnid']=$c_id;
        // echo $c_id;exit;
        $contents=$newsModel->where($condition1)->field('n_id,news_img,news_title')->order(' `news_time` desc')->select();

        // self::$news =$newsModel->where($condition1)->order(' `news_time` desc')->select();
        $news=json_encode($contents);
        echo $news;

    }







}